<!DOCTYPE html>
<html lang="en">
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script type="text/javascript" src="../static/easyUI/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../static/easyUI/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form class="layui-form" action="" lay-filter="formFilter">
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test1">
                <i class="layui-icon">&#xe67c;</i>上传头像
            </button>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="title" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">密码长度最少八位</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所在省</label>
        <div class="layui-input-block">
            <select name="city" lay-verify="required">
                <option value=""></option>
                <option value="0">北京</option>
                <option value="1">上海</option>
                <option value="2">广州</option>
                <option value="3">深圳</option>
                <option value="4">杭州</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">来源</label>
        <div class="layui-input-block">
            <input type="checkbox" name="like[write]" title="公众号推荐">
            <input type="checkbox" name="like[read]" title="GitHub" checked>
            <input type="checkbox" name="like[dai]" title="百度搜索">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否允许其他ip登录</label>
        <div class="layui-input-block">
            <input type="checkbox" name="switch" lay-skin="switch">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex" value="男" title="男">
            <input type="radio" name="sex" value="女" title="女" checked>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">自我介绍</label>
        <div class="layui-input-block">
            <textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo" id="save">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    //Demo
    var formJson ;
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            formJson = JSON.stringify(data.field);
            return JSON.stringify(data.field);
        });
    });
    
    layui.use('upload',function(){
        var upload =layui.upload;
        
        var uploadInst = upload.render({
            elem:'#test1',
            url:'/EasyAdmin/user/update',
            auto:false,
            bindAction:'#save',
            data:{
                content:function(){
                    return "{'id':'123','name':'wangbo'}";
                }
            },
            done:function (res) {
                layer.msg(res);
                console.log(res);
            },
            error:function (error) {
                
            }
        })
    })
</script>
</body>
</html>